from bs4 import BeautifulSoup
import urllib.request,urllib.response



##模拟浏览器请求，获得网页源代码
def gethtml(url):
    header = {"User-Agent": '''Mozilla/5.0(Windows NT 10.0; Win64; x64) 
    AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'''}

    request = urllib.request.Request(url, headers=header)
    response = urllib.request.urlopen(request)
    html = response.read()
    return html

def getdata(html):
    soup=BeautifulSoup(html)
    data=[]
    for i in soup.find_all("li", data="_blank") :
        print(i)
    return data


if __name__ == '__main__':
    url = "https://vacations.ctrip.com/"
    html = gethtml(url)
    datapath=""
    getdata(html)
